package com.ruoyi.project.system.service.impl;


import com.ruoyi.project.system.domain.SysDiscount;
import com.ruoyi.project.system.domain.SysUserDiscount;
import com.ruoyi.project.system.mapper.SysUserDiscountDao;
import com.ruoyi.project.system.service.SysUserDiscountService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (SysUserDiscount)表服务实现类
 *
 * @author makejava
 * @since 2020-03-04 19:16:56
 */
@Service("sysUserDiscountService")
public class SysUserDiscountServiceImpl implements SysUserDiscountService {
    @Resource
    private SysUserDiscountDao sysUserDiscountDao;

    /**
     * 通过ID查询单条数据
     *
     * @param discountId 主键
     * @return 实例对象
     */
    @Override
    public SysUserDiscount queryById(Long discountId) {
        return this.sysUserDiscountDao.queryById(discountId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<SysUserDiscount> queryAllByLimit(int offset, int limit) {
        return this.sysUserDiscountDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<SysDiscount> queryAll(SysUserDiscount sysUserDiscount) {
        return this.sysUserDiscountDao.queryAll(sysUserDiscount);
    }

    /**
     * 新增数据
     *
     * @param sysUserDiscount 实例对象
     * @return 实例对象
     */
    @Override
    public SysUserDiscount insert(SysUserDiscount sysUserDiscount) {
        this.sysUserDiscountDao.insert(sysUserDiscount);
        return sysUserDiscount;
    }

    /**
     * 修改数据
     *
     * @param sysUserDiscount 实例对象
     * @return 实例对象
     */
    @Override
    public SysUserDiscount update(SysUserDiscount sysUserDiscount) {
        this.sysUserDiscountDao.update(sysUserDiscount);
        return this.queryById(sysUserDiscount.getDiscountId());
    }

    /**
     * 通过主键删除数据
     *
     * @param discountId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long discountId) {
        return this.sysUserDiscountDao.deleteById(discountId) > 0;
    }
}